package day18.tarena.Thred;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class HomeWork extends Thread  implements ActionListener {
	
	private int time = 7200;
	JLabel jl = new JLabel("  2:00:00  ");
	JProgressBar jdt= new JProgressBar(JProgressBar.HORIZONTAL);
	JLabel jl2 = new JLabel();
	
	public void actionPerformed(ActionEvent e) {
			this.start();
	}

	public void run() {
		for (int i = time; i >= 0; i--) {
			int h = i / 3600;		//get 2
			int m = i % 3600 / 60;    //get 0/60m  --->   60s
			int s = i % 60;          //get
			String str = h + ":" + m + ":" + s;
			
			jl.setText(str);
			try {
				Thread.sleep(1000);
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
	}
	
	public void rr(){
		for(int i=0;i<100;i++){
		}
	}
	
	public HomeWork(){
    	JFrame jf = new JFrame("倒计时");
    	jf.setLayout(new FlowLayout());
    	JButton jb  = new JButton("倒计时开始");
    	jb.addActionListener(this);
    	
    	jf.add(jl);
    	jf.add(jb);
		jf.setLocation(400,400);
		jf.pack();
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	}
	public static void main(String[] args) {
		new HomeWork();
	}
}
